<style type="text/css" media="screen">
   
   
    .layui-select-disabled .layui-disabled{
    	color:#666 !important;
    }
   
</style>

<div class="layui-form" id="layuiadmin-form-admin" lay-filter="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
	<div class="layui-row">
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    客户
                </label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" value="{$model.customer_name ?? ''}" name="customer_name" placeholder="请输入获得客户时间" required="" type="text" readonly />
                </div>
            </div>
        </div>
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    联系人
                </label>
                <div class="layui-input-block">
                     <input autocomplete="off" class="layui-input" value="{$model.title ?? ''}" name="customer_name" placeholder="请输入联系人" required="" type="text"  readonly/>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    跟进时间
                </label>
                <div class="layui-input-block">
                    <input autocomplete="off" class="layui-input" name="follow_time" id="follow_up_time" placeholder="请输入跟进时间" required="" type="text" readonly>
                    </input>
                </div>
            </div>
        </div>
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    联系方式
                </label>
                <div class="layui-input-block">
                    <select name="follow_contact_id" lay-search="">
                        <option value="">请选择联系方式</option>
                        {foreach $follow_status as $key=>$vo}
                             <option value="{$vo.id}">{$vo.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md12">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    跟进结果
                </label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" id="LAY_demo_editor" lay-verify="content" name="content"></textarea>
                </div>
            </div>
        </div>
  		<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    跟进阶段
                </label>
                <div class="layui-input-block">
                    <select name="follow_stage_name_id" lay-search="">
                        <option value="">请选择客户状态</option>
                        {foreach $follow_stage as $key=>$vo}
                             <option value="{$vo.id}">{$vo.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
        </div>
		<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    更新客户状态
                </label>
                <div class="layui-input-block">
                    <select name="update_status_id" lay-search="">
                        <option value="">请选择客户状态</option>
                        {foreach $customer_status as $key=>$vo}
                             <option value="{$vo.id}">{$vo.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
        </div>
   		<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    当前客户状态
                </label>
                <div class="layui-input-block">
                    <input autocomplete ="off" class="layui-input" name="then_status" value="{$model.CustomerStatus.name ?? ''}" placeholder="请输入当前客户状态" required="" type="text" readonly>
                    </input>
                </div>
            </div>
        </div>
        <div class="layui-col-xs12 layui-col-sm6 layui-col-md12">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    相关文档
                </label>
                <div class="layui-input-block" id="layui-file">
                    <div class="layui-upload">
                        <button class="layui-btn layui-btn-normal" id="testList" type="button">
                            选择多文件
                        </button>
                        <div class="layui-upload-list">
                            <table class="layui-table">
                                <thead>
                                    <tr>
                                        <th>
                                            文件名
                                        </th>
                                        <th>
                                            大小
                                        </th>
                                        <th>
                                            状态
                                        </th>
                                        <th>
                                            操作
                                        </th>
                                    </tr>
								</thead>
                                <tbody id="demoList">
                                </tbody>
                            </table>
                        </div>
                        <button class="layui-btn" id="testListAction" type="button">
                            开始上传
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input id="LAY-user-back-submit" lay-filter="LAY-user-back-submit" lay-submit="" type="button" value="确认">
        </input>
    </div>
</div>
<script src="/static/admin/layui/layui.js">
</script>
<script>
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
        treeTable: '../admin/lib/extend/authtree'
    }).use(['index', 'form', 'laydate','upload'], function () {
        var $ = layui.$, form = layui.form, laydate = layui.laydate ,upload = layui.upload;
        //日期范围
        laydate.render({
            elem: '#follow_up_time'
            , trigger: 'click'//呼出事件改成click
            ,type: 'datetime'
            , value: new Date()
        });

//多文件列表示例
var j=0;
  var demoListView = $('#demoList')
  ,uploadListIns = upload.render({
    elem: '#testList'
    ,url: "{:url('customer/upload')}"
    ,accept: 'file'
    ,multiple: true
    ,auto: false
    ,bindAction: '#testListAction'
    ,choose: function(obj){   
      var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
      //读取本地文件
      obj.preview(function(index, file, result){
        var tr = $(['<tr id="upload-'+ index +'">'
          ,'<td>'+ file.name +'</td>'
          ,'<td>'+ (file.size/1014).toFixed(1) +'kb</td>'
          ,'<td>等待上传</td>'
          ,'<td>'
            ,'<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
            ,'<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
          ,'</td>'
        ,'</tr>'].join(''));
        
        //单个重传
        tr.find('.demo-reload').on('click', function(){
          obj.upload(index, file);
        });
        
        //删除
        tr.find('.demo-delete').on('click', function(){
          delete files[index]; //删除对应的文件
          tr.remove();
          uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
        });
        
        demoListView.append(tr);
      });
    }
    ,done: function(res, index, upload){
      if(res.code == 0){ //上传成功
        var tr = demoListView.find('tr#upload-'+ index)
        ,tds = tr.children();
        tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
        tds.eq(3).html(''); //清空操作
        $('#layui-file').append('<input type="hidden" name="pc_src['+j+']" value="'+res.data['src']+'" />');
        $('#layui-file').append('<input type="hidden" name="pc_name['+j+']" value="'+res.data['name']+'" />');
        j++;
        return delete this.files[index]; //删除文件队列已经上传成功的文件

      }
      this.error(index, upload);
    }
    ,error: function(index, upload){
      var tr = demoListView.find('tr#upload-'+ index)
      ,tds = tr.children();
      tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
      tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
    }
  });
    });
</script>